<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>05缩放滑块控件</title>
  <link rel="stylesheet" href="../ol/ol.css">
  <style>
    html, body {
      margin: 0;
    }
    #map {
      width: 400px;
      height: 400px;
    }
  </style>
</head>
<body>
<div id="mousePositionTxt"></div>
<div id="map"></div>

<script src="../ol/ol.js"></script>
<script>
  const map = new ol.Map({
    target: 'map',
    layers: [
      new ol.layer.Tile({
        source: new ol.source.OSM()
      })
    ],
    view: new ol.View({
      projection: 'EPSG:4326',
      center: [114.064839, 22.548857],
      zoom: 2
    }),
    // 添加控件
    controls: ol.control.defaults.defaults().extend([
      // 缩放滑块控件
      new ol.control.ZoomSlider()
    ])
  })

</script>
</body>
</html>